package com.echo.controller;

import com.echo.context.BaseContext;
import com.echo.context.WisUserIdContext;
import com.echo.dto.CourseDTO;
import com.echo.entity.Course;
import com.echo.entity.ExamRecord;
import com.echo.entity.Questionnaire;
import com.echo.result.ResultVO;
import com.echo.service.ICourseService;
import com.echo.vo.CourseVo;
import com.echo.vo.ExamRecordVo;
import com.echo.vo.QuestionnaireVo;
import com.echo.vo.RecordDetailVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.checkerframework.checker.units.qual.C;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Tag(name = "Course APIs")
@RequestMapping("/api/course")
@RequiredArgsConstructor
public class CourseController {
    private final ICourseService courseService;

    // 1.添加课程
    @PostMapping("/addCourse")
    public ResultVO<Integer> createCourse(@RequestBody CourseDTO courseDTO) {


        return courseService.createCourse(courseDTO);
    }

    // 2.查看所有课程
    @GetMapping("/getAllCourses")
    public ResultVO<List<Course>> getAllCourses() {
        return courseService.getAllCourses();
    }

    // 3.查看课程详情
    @GetMapping("/{courseId}")
    public ResultVO<CourseVo> getCourseDetail(
            @PathVariable Integer courseId) {
        return courseService.getCourseDetail(courseId);
    }

    // 4.1 查看课程所有作业记录
    @GetMapping("/{courseId}/exam-course-records-list")
    public ResultVO<List<ExamRecordVo>> getExamRecordsList(
            @PathVariable Integer courseId) {
        return ResultVO.success(courseService.getExamRecordsList(courseId));
    }
    //4.2 查看作业的对应的详细记录：examController.getRecordDetail
    //4.3 添加课程试卷
    // 5.1 查看课程所有问卷
    @GetMapping("/{courseId}/questionnairesList")
    public ResultVO<List<Questionnaire>> getQuestionnairesList(
            @PathVariable Integer courseId) {
        return ResultVO.success(courseService.getQuestionnairesList(courseId));
    }
    //5.2 查看课程问卷对应的详细信息
    @GetMapping("/{questionnaireId}/questionnairesDetail")
    public ResultVO<QuestionnaireVo> getQuestionnairesDetail(
            @PathVariable Integer questionnaireId) {
        return ResultVO.success(courseService.getQuestionnairesDetail(questionnaireId));
    }
    // 新增问卷：

    // 新增试卷
}
